//
//  DeviceInfo.swift
//  SwiftNote
//
//  Created by PerhapYs on 2021/12/16.
//

import AdSupport
import UIKit

struct AppInfo{
    
    static let infoDictionary = Bundle.main.infoDictionary
    //App 名称
    static let appDisplayName: String = Bundle.main.infoDictionary!["CFBundleDisplayName"] as! String
    
    ///App 版本号
    static var appVersion: String {
        get {
            let infoDictionary = Bundle.main.infoDictionary ?? [:]
            let version = (infoDictionary["CFBundleShortVersionString"] as? String) ?? ""
            return version
        }
    }
    //Applogo
    static let appLogo : String = {
        if let info = Bundle.main.infoDictionary ,
           let bundleIcons = info["CFBundleIcons"] as? Dictionary<String,Any>,
           let primaryIcon = bundleIcons["CFBundlePrimaryIcon"] as? Dictionary<String,Any>,
           let iconfiles = primaryIcon["CFBundleIconFiles"] as? Array<Any>,
           iconfiles.count > 0,
           let icon = iconfiles.last as? String
        {
           return icon
       }
        return ""
    }()
    ///设备名称
    public var device_name: String {
        get {
            return UIDevice.current.name
        }
    }
    ///设备类型 iPhone ipad
    public var device_model: String {
        get {
            return UIDevice.current.model
        }
    }
    ///设备系统名称
    public var device_system_name: String {
        get {
            return UIDevice.current.systemName
        }
    }
    ///设备系统版本号
    public var device_system_version: String {
        get {
            return UIDevice.current.systemVersion
        }
    }
    ///设备设备的唯一标识 ：卸载重装之后不会改变
    static let identifier: String = {
       
        return ASIdentifierManager.shared().advertisingIdentifier.uuidString
    }()
    
    public var IDFV : String{
        get{
            if let UUID = UIDevice.current.identifierForVendor{
                return UUID.uuidString
            }
            return "0000"
        }
    }
}
